package entity

import (
	"core/datetime"
	"time"
)

const (
	StdPkgProp_fix        = uint8(10)
	StdPkgProp_state      = uint8(20)
	StdPkgProp_value      = uint8(30)
	StdPkgProp_statevalue = uint8(40)
	StdPkgProp_config     = uint8(50)
)

type StdPkgProp struct {
	Id   string `json:"id"   bson:"_id"                        gorm:"column:id;size:20;comment:通道编号;"`
	Name string `json:"name"  bson:"name"                         gorm:"column:name;size:50;comment:名称;"`

	// 10 固定属性  20 检测状态    30 检测值   40 有状态的检测值属性   50 可配置属性
	Type uint8 `json:"type"    bson:"type"                       gorm:"column:prop_type;comment:属性类型;"`

	Fv float32 `json:"fv"      bson:"fv"                      gorm:"column:prop_id;size:10;comment:数值;"`
	Sv string  `json:"sv"           bson:"sv"               gorm:"column:prop_id;size:10;comment:显示值;"`
	//正常、30.0  显示值  启动、故障、停止

	Vl    string `json:"vl"    bson:"vl"     gorm:"column:vl;size:20;comment:状态;"`
	Vll   string `json:"vll"   bson:"vll"      gorm:"column:vll;size:20;comment:状态;"`
	Vh    string `json:"vh"    bson:"vh"     gorm:"column:vh;size:20;comment:状态;"`
	Vhh   string `json:"vhh"   bson:"vhh"      gorm:"column:vhh;size:20;comment:状态;"`
	Unit  string `json:"unit"  bson:"unit"       gorm:"column:unit;size:10;comment:状态;"`
	State string `json:"state"  bson:"state"       gorm:"column:state;size:10;comment:状态;"`
	//正常、故障、一级警情、二级警情
	RaiseEvent bool   `json:"raiseEvent"   bson:"raiseEvent"       gorm:"column:raise_event;comment:是否触发警情;"`
	CrtDt      string `json:"crtDt"    bson:"crtDt"     gorm:"column:crtDt;size:20;comment:状态;"`
	Monitor    bool   `json:"monitor"    bson:"monitor"     gorm:"column:monitor;comment:是否监测属性;"`
}

func NewStdPkgProp(id, name, sv string, Type uint8, Fv float32) *StdPkgProp {

	return &StdPkgProp{
		Id:         id,
		Name:       name,
		Type:       Type,
		Fv:         Fv,
		Sv:         sv,
		Vl:         "",
		Vll:        "",
		Vh:         "",
		Vhh:        "",
		Unit:       "",
		State:      "",
		RaiseEvent: false,
		CrtDt:      datetime.FormatDateTime(time.Now()),
	}
}
